<template>
	<!-- 添加弹框 -->
	<el-dialog title="" visible :show-close="false" :append-to-body="true" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
	    <div class="bt">学生公立校成绩添加</div>
		<el-form label-width="100px" class="form">
			<el-form-item label="班级名称">
				<el-select v-model="vbjid" @change="xsgetcomlist"  class="select-block" placeholder="请选择班级">
					<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="学生名称">
				 <!--<el-input v-model="vxsid"  placeholder="请输入学生名称" icon="add" class="select-block"></el-input>-->
				 <el-select v-model="vxsid"  class="select-block" placeholder="请选择班级">
					<el-option :label="v.zwm" :value="v.id" v-for="v in xscomboxlist"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="学生成绩">
				 <el-input v-model="vcj" placeholder="请输入学生成绩" icon="add" class="select-block"></el-input>
			</el-form-item>
            <el-form-item label="成绩类型">
            	<el-select v-model="vlx"  class="select-block" placeholder="请输入成绩类型">
					<el-option :label="v.mc" :value="v.mc" v-for="v in cjcomboxlist"></el-option>
				</el-select>
				 <!--<el-input v-model="vlx" placeholder="请输入成绩类型" icon="add" class="select-block"></el-input>-->
			</el-form-item>
			<el-form-item label="排名">
				 <el-input v-model="vpm" placeholder="请输入排名" icon="add" class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="附件1">
				 <el-input v-model="vfj1" placeholder="请输入" icon="add" class="select-block"></el-input>
			</el-form-item>
		</el-form>
		<el-button type="primary" class="submit" @click="submit">添加</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data() {
			return {
				vbjid:'',
				vxsid: '',
				vcj: '',
				vlx: '',
				vpm: '',
				vfj1: '',
				dialogTableVisible: true,
				 comboxlist:[],//下拉框 动态的
				 cjcomboxlist:[],
				 xscomboxlist:[],
			}
		},
		created () {
				this.getcomlist();
				this.cjgetcomlist();
				this.xsgetcomlist();
		},
		methods: {
			
			submit() {
			  this.$store.state.loading = true;
			    if(!this.vxsid) {
					this.$message.warning('请填写学生名称');
					this.$store.state.loading = false;
					return;
				} 
				else if(!this.vcj){
					this.$message.warning('请填写学生成绩');
					this.$store.state.loading = false;
					return;
				}
				else if(!this.vlx){
					this.$message.warning('请选择类型');
					this.$store.state.loading = false;
					return;
				}
				else if(!this.vpm){
					this.$message.warning('请填写排名');
					this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					xsid: this.vxsid,
					cj: this.vcj,
					lx:this.vlx,
					pm: this.vpm,
					fj1:this.vfj1,
					yhid: logininfo.id,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'xsxwcj/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
						    this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},
		getcomlist(){
			var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                 yhid:logininfo.id+'',
                    xxid:logininfo.xxid+''
               })
             //执行
                 this.axios.post(this.$store.state.api + 'bj/getbj',  params2 )
                 .then(res => {
                 let data = res.data.data;
                  let list = data.list;
                  this.comboxlist = list;
                 }).catch(res => {
				})
        },
        cjgetcomlist(){
			var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                 yhid:logininfo.id+'',
                    xxid:logininfo.xxid+''
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xxcode/getxwcjxlk',  params2 )
                 .then(res => {
                 let data = res.data.data;
                  let list = data.list;
                  this.cjcomboxlist = list;
                 }).catch(res => {
				})
        },
        xsgetcomlist(){
        	var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                 bjid:this.vbjid,
                    yhid:logininfo.id,
                    xxid:logininfo.xxid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xs/list',  params2 )
                 .then(res => {
                 let data = res.data.data;
                  let list = data.list;
                  this.xscomboxlist = list;
                 }).catch(res => {
				})
        },
//      getlscomlist(){
//          var logininfo = JSON.parse(localStorage.logininfo) ;
//          this.axios.get(this.$store.state.api + 'ls/mc',{
//              params:{
//                  xxid:logininfo.xxid+''
//              }
//          }).then( res => {
//             let data = res.data.data;
//                let list = data.list;
//                this.lscomboxlist = list;
//
//          }).catch( res => {
//          })
//      },
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less">
.wrap {
	text-align: center;
}
.bt{
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		color:white;
		text-align:left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}

.form {
	text-align: left;
	margin-top: 20px;
}
 .input {
					width: 300px;
					display: inline-block;
			}

.select-block {
	display: block;
	width: 85%;
}

.submit {
	width: 120px;
}
.el-form-item {
    margin-bottom: 10px;
}
</style>
